package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.info.domain.FhInfoEquip;
import com.ruoyi.info.service.FhInfoEquipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 装备管理Controller
 *
 * @author zcc
 * @date 2024-12-25
 */
@Api(description ="装备管理接口列表")
@RestController
@RequestMapping("/info/fhInfoEquip")
public class FhInfoEquipController extends BaseController {
    @Autowired
    private FhInfoEquipService service;

    @ApiOperation("查询装备管理列表")
    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<FhInfoEquip>> list(@RequestBody FhInfoEquip query, Pageable page) {
        query.setEquipType("0");
        List<FhInfoEquip> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

//    @ApiOperation("导出装备管理列表")
//    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:export')")
//    @Log(title = "装备管理", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public ResponseEntity<String> export(${_className.query} query) {
//        List<FhInfoEquip> list = service.selectList(query, null);
//        ExcelUtil<${_className.vo}> util = new ExcelUtil<>(${_className.vo}.class);
//        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "装备管理数据"));
//    }

    @ApiOperation("获取装备管理详细信息")
    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:query')")
    @GetMapping(value = "/{equipId}")
    public ResponseEntity<FhInfoEquip> getInfo(@PathVariable("equipId") Long equipId) {
        return ResponseEntity.ok(service.selectByEquipId(equipId));
    }

    @ApiOperation("新增装备管理")
    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:add')")
    @Log(title = "装备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhInfoEquip fhInfoEquip) {
        return ResponseEntity.ok(service.insert(fhInfoEquip));
    }

    @ApiOperation("修改装备管理")
    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:edit')")
    @Log(title = "装备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhInfoEquip fhInfoEquip) {
        return ResponseEntity.ok(service.update(fhInfoEquip));
    }

    @ApiOperation("删除装备管理")
    @PreAuthorize("@ss.hasPermi('info:fhInfoEquip:remove')")
    @Log(title = "装备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipIds}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] equipIds) {
        return ResponseEntity.ok(service.deleteByEquipIds(equipIds));
    }
}
